import React, { ReactElement, useEffect } from 'react';
import { View } from 'react-native';
import { NavigationScreenProps } from 'react-navigation';

import Provider from './reducer';
import styles from './style';
import Header from './components/Header';
import Container from './components/Container';
import { setOrderInfo } from './actions';

export default ({ navigation }: NavigationScreenProps): ReactElement => {
  const orderInfo = navigation.getParam('orderInfo');

  useEffect((): void => {
    if (orderInfo) {
      setOrderInfo(orderInfo);
    }
  }, [orderInfo]);
  return (
    <Provider>
      <View style={styles.container}>
        <Header />
        <Container />
      </View>
    </Provider>
  );
};
